<?php

namespace App\Controllers;

use App\Facades\Log;
use App\Models\UserModel;

class UserController extends Controller
{
    public function index()
    {
        Log::error('哈哈哈', ['test' => 'haah']);
        echo "haah";
    }

    public function list()
    {
        $list = UserModel::query()->get();
        return jsonResponse(['list' => $list]);
    }

    public function info($uid)
    {
        $info = UserModel::query()->where('id', '=', $uid)->get();
        if ($info) {
            return jsonResponse(['info' => $info]);
        }
        return jsonResponse('not found', 404);
    }

    public function delete($uid)
    {
        $info = UserModel::query()->where('id', '=', $uid)->delete();
        echo "delete $info";
    }
}
